import React from 'react'
import style from './index.less'
import { connect } from 'dva';
import { Card, Row, Col } from 'antd'



/**
 * [RiskAnalysis 风险分析]
 */

import RealisationList from '../../components/RealisationList'
import RealisationSummary from '../../components/RealisationSummary'
import DataDate from '../../components/DataDate'
const ContentDisplay = (props) => {
  const myProps = {
    productId: props.lPortId,
    date: props.date || props.lastDate
  }
  const maxValue = props.realisationSummary && props.realisationSummary.list && (props.realisationSummary.list.sort((a, b) => b.ratio - a.ratio)[0].ratio).toPercent()||'-'
  // console.log(123,props.realisationSummary,maxValue);
  
  return (
    <div className="dataArea">
      <DataDate {...props} disabled={true} />
      <Card title="最近七天变现比例" extra={<span>七天累计实现比例：<b>{maxValue}</b></span>} bordered={false}>
        {/*<Row gutter={20}>*/}
         <Row>
          <Col span={12}>
          <RealisationSummary {...props} />
          </Col>
          <Col span={12}>
          <RealisationList {...props} />
          </Col>
        </Row>
        <Row>
          <Col>
            {/*<ol style={{ color: '#999' }}>*/}
            <ol style={{ color: '#4a4a4a' }}>
              <li>股票：前一交易日市场成交额的30% </li>
              <li>债券：最近30个交易日市场成交金额的平均值 </li>
              <li>基金：上一公告日基金总份额的10%*单日单位净值（可在二级市场交易的基金同股票变现规则） </li>
              <li>现金：当天全部变现 </li>
              <li>逆回购：买入返售证券市场／逆回购天数 </li>
              <li>其他资产：到期变现</li>
            </ol>
          </Col>
        </Row>
      </Card>

    </div>
  )
}

import { NoData } from '../../../../components'
const RiskAnalysis = (props) => {

  return (
    <div className={style.root}>
     {
        (props.lPortId)?<ContentDisplay {...props} />:<NoData />
      }
    </div>
  );
}

export default connect()(RiskAnalysis)